<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
 <!DOCTYPE html>
<html>

<head>
	<base href="/">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    

    <title>用户</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">

    <link rel="shortcut icon" href="favicon.ico"> 
    <link href="static/templet/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="static/templet/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="static/templet/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="static/templet/css/animate.min.css" rel="stylesheet">
    <link href="static/templet/css/style.min862f.css?v=4.1.0" rel="stylesheet">

</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
    <form action="keyWordG/proxy/reviewList" method="post" id="keyWordReviewForm">
        <div class="row">
        	<!-- 检索 -->
        	<div class="col-sm-12">
        		<table class="table table-hover">
        			<tr>
        				<td style="width:3%;">
        					<div class="input-group">
							     <input type="text" class="form-control" onkeydown="onKeyDown(event)" name="userName" id="userName" value="${pam.userName}" placeholder="请输入用户名"/>
							</div>
        				</td>
        				<td style="width:3%;" >
        					<div class="input-group">
							     <input type="text" class="form-control" onkeydown="onKeyDown(event)" name="domain" id="domain" value="${pam.domain}" placeholder="请输入域名"/>
							</div>
        				</td>
        				<td style="width:20%;">
        					<select class="form-control" name="typeValue" id="typeValue" data-placeholder="搜索引擎" style="vertical-align:top;width: 120px;">
					           <option value="">搜索引擎</option>
					            <c:forEach items="${engineList}" var="engin">
					            	<option value="${engin.code }" <c:if test="${pam.typeValue == engin.code}">selected</c:if>>${engin.name  }</option>
					            </c:forEach>
					        </select>
        				</td>
        				<td style="width:1%;">
        					<span style="float:right;"><button type="button" class="btn btn-primary" onclick="searchs();">检索</button></span>
        				</td>
        			</tr>
        		</table>
			</div>
			<!-- 内容 -->
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <table class="table table-hover">
                            <thead>
                                <tr>
                                 	<th class="text-center"><input type="checkbox" id="checked_all" onclick="checkOrCancelAll();"/>&nbsp;&nbsp;&nbsp;&nbsp;<span id="choose">全选</span></th>
                                    <th class="text-center">id</th>
                                    <th class="text-center">用户名</th>
                                    <th class="text-center">关键词</th>
                                    <th class="text-center">类型</th>
                                    <th class="text-center">域名</th>
                                    <th class="text-center">指数</th>
                                    <th class="text-center">单价</th>
                                    <th class="text-center">目标排名</th>
                                    <th class="text-center">状态</th>
                                    <th class="text-center">用户状态</th>
                                    <th class="text-center">用户服务状态</th>
                                    <th class="text-center">添加时间</th>
                                    <th class="text-center">操作</th>
                                </tr>
                            </thead>
                            <tbody>
							<c:forEach items="${page.list}" var="review" varStatus="vs">
                            	<tr class="text-center">
                             		<td><input type="checkbox" class="checked_pro" name="checkbox" value="${review.id }"/></td>
                                    <td>${review.id }</td>
									<td>${review.userName }</td>
									<td>${review.keyWordName }</td>
									<td>${review.typeValue }</td>
									<td>${review.domain }</td>
									<td>
										<c:choose>
											<c:when test="${review.keywordIndex == '-1'}">
												0
											</c:when>
											<c:otherwise>
												${review.keywordIndex }
											</c:otherwise>
										</c:choose>
									</td>
									<td>${review.price }</td>
									<td>${review.targetRanking }</td>
									<td>
										<c:if test="${review.state == '00'}">
											待审核
										</c:if>
										<c:if test="${review.state == '01'}">
											使用中
										</c:if>
										<c:if test="${review.state == '02'}">
											已停用
										</c:if>
										<c:if test="${review.state == '03'}">
											禁用
										</c:if>
									</td>
									<td>
										<c:if test="${review.userState == '01'}">
											启用
										</c:if>
										<c:if test="${review.userState == '02'}">
											禁用
										</c:if>
									</td>
									<td>
										<c:if test="${review.serviceState == '00'}">
											服务
										</c:if>
										<c:if test="${review.serviceState == '01'}">
											停止服务
										</c:if>
									</td>
									<td>${review.createTime }</td>
                                    <td><a href="javascript:keyWordReview('${review.id }');" title="审核">审核</a> 
                                    </td>
                                </tr>
                            </c:forEach>
                            </tbody>
                        </table>
                        <jsp:include page="/WEB-INF/jsp/page.jsp">
                        	<jsp:param value="keyWordReviewForm" name="form"/>
                        </jsp:include>
                    </div>
                    <div class="col-sm-12">
		        		<table class="table table-hover">
		        			<tr>
		        				<td style="width:1%;">
		        					<span style="float:left;"><button type="button" class="btn btn-primary" onclick="keyWordReviewList();">批量审批</button></span>
		        				</td>
		        			</tr>
		        		</table>
				   </div>
                </div>
            </div>
        </div>
        </form>
    </div>
    <script src="static/templet/js/jquery.min.js?v=2.1.4"></script>
    <script src="static/templet/js/bootstrap.min.js?v=3.3.5"></script>
    <script src="static/templet/js/plugins/peity/jquery.peity.min.js"></script>
    <script src="static/templet/js/plugins/layer/layer.min.js"></script>
    <script src="static/templet/js/iframe.min.js"></script>
    <script type="text/javascript">
    
    function searchs(){
    	$("#keyWordReviewForm").submit();
    }
    
  	//全选 全不选
    //页面加载的时候,所有的复选框都是未选中的状态
	function checkOrCancelAll(){
		//1.获取checkbo的元素对象
		var chElt=document.getElementById("checked_all");
		//2.获取选中状态
		var checkedElt=chElt.checked;
		console.log(checkedElt)
		//3.若checked=true,将所有的复选框选中,checked=false,将所有的复选框取消
		var allCheck=document.getElementsByName("checkbox");
		//4.循环遍历取出每一个复选框中的元素
		var mySpan=document.getElementById("choose");
		if(checkedElt){
			//全选
			for(var i=0;i<allCheck.length;i++){
				//设置复选框的选中状态
				allCheck[i].checked=true;
			}
			mySpan.innerHTML="取消全选";
		}else{
			//取消全选
			for(var i=0;i<allCheck.length;i++){
				allCheck[i].checked=false;
			}
			mySpan.innerHTML="全选";
		}
	}
    
    
	
	//批量修改
	function keyWordReviewList() {
	    //获取所有被选中的记录
	    var rows = document.getElementsByName("checkbox");
	    if (rows.length== 0) {
	        alert("请先选择要修改的记录!");
	        return;
	    }
	    var ids = '';
	    for (var i = 0; i < rows.length; i++) {
	    	if(rows[i].checked){
	    		ids += rows[i].value + ",";
	    	}
	    }
	    ids = ids.substring(0, ids.length - 1);
	    keyWordReview(ids);
	}
	
	//修改
	function keyWordReview(ids){
		layer.confirm('是否通过审核？',function(index){
			$.ajax({
				type: 'get',
				url: 'keyWordG/proxy/keyWordReview',
				data: {ids : ids},
				success: function(data){
					layer.msg('成功!',{icon: 1,time:2000});
					setTimeout(function(){
						window.location.reload();
					},1000)
				},
				error:function(data) {
					console.log(data.msg);
				},
			});		
		});
	}
    </script>

</body>

</html>